package com.yjs.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yjs.bean.UserInfo;
import com.yjs.mapper.UserInfoMapper;
import com.yjs.service.UserInfoService;

/**
 * @author yjs
 * @create 2020-09-16-11:50
 * 用户实现层
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {
    //注入用户mapper
    @Autowired
    UserInfoMapper userInfoMapper;

    //登录
    @Override
    public UserInfo login(UserInfo userInfo) {
        UserInfo login = userInfoMapper.login(userInfo);
        if (login!=null){
            return login;
        }
        return null;
    }
    //注册
    @Override
    public void register(UserInfo userInfo) {
        userInfoMapper.register(userInfo);
    }
    //查询用户信息
    @Override
    public UserInfo getOneUser(String username) {
        UserInfo oneUser = userInfoMapper.getOneUser(username);
        return oneUser!=null?oneUser:null;
    }
    //修改用户手机号和邮箱
    @Override
    public void updUser(UserInfo userInfo) {
        userInfoMapper.updUser(userInfo);
    }
    //修改用户密码
    @Override
    public void updPwd(Integer uid, String confirmpwd) {
        UserInfo userInfo = new UserInfo();
        userInfo.setUid(uid);
        userInfo.setPassword(confirmpwd);
        userInfoMapper.updPwd(userInfo);
    }


}
